import java.util.Scanner;
import java.util.regex.Pattern;

public class Zhengze {
    public static void main(String[] args) {
        boolean register = true;
        boolean register1 = true;
        boolean register2 = true;
        boolean register3 = true;
        Scanner scan = new Scanner(System.in);
        while (register) {
            System.out.println("输入用户名，要求6-20位字母、数字、下划线组成");
            String id = scan.next();
            if (id.matches("^[a-zA-Z0-9_]{6,20}$")) {//账号类型判断
                while (register1) {
                    System.out.println("输入密码，要求(必须包含大小写字母和数字的组合，不能使用特殊字符，长度不少于6位）");
                    String secret = scan.next();
                    if (secret.matches("^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{6,}$")) {  //密码类型判断
                        while (register2) {
                            System.out.println(" 输入确认密码，要求和密码一致");
                            String secretConfirm = scan.next();
                            if (secretConfirm.equals(secret)) {//确认密码判断
                                while (register3) {
                                    //邮箱类型判断
                                    System.out.println("输入邮箱");
                                    String userEmail = scan.next();
                                    if (userEmail.matches("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$")) {
                                        System.out.println("注册成功");
                                        register1 = false;
                                        register2 = false;
                                        register3 = false;
                                        register = false;

                                    } else {
                                        System.out.println("邮箱格式错误");
                                    }
                                }
                            } else {
                                System.out.println("两次密码不一致");
                            }
                        }

                    } else {
                        System.out.println("密码类型错误,请重新输入");
                    }
                }
            } else {
                System.out.println("用户名格式不正确，请重新输入");
            }
        }
    }


}// last
